﻿<!-- #include file="../Include/Admin_Onlogin.asp" -->
<%
Data_Name = "{prefix}Fieldset"
strFileName = "Admin_Fieldset.asp"
Dim sqlAuth, rsAuth, PurviewID
sqlAuth = "Select AuthID From Admin_Auth Where href='Admin/" & strFileName & "' Order By sort Asc,AuthID Asc"
Call Exec(rsAuth,sqlAuth,2)
If rsAuth.BOF And rsAuth.EOF Then
	PurviewID = 0
Else
	PurviewID = rsAuth(0)
	CheckPurview PurviewID,0
End If
rsAuth.Close
Set rsAuth = Nothing
Select Case Action
Case "Add"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldAdd' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Add()
Case "SaveAdd"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldInsert' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call SaveAdd()
Case "Modify"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldEdit' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Modify()
Case "SaveModify"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldUpdate' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call SaveModify()
Case "FieldStatus"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldStatus' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call FieldStatus()
Case "ListOrder"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldOrder' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call ListOrder()
Case "Update"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldUpdate' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Update()
Case "Del"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Module/FieldDel' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Del()
Case Else
    Call Main()
End Select
If FoundErr = True Then
	Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Call CloseConn()

Sub Main()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		ChannelID = Code_CLng(Trim(Code_Form("ChannelID")))
		Sql = "Select * From ["&Data_Name&"]"
		If ChannelID<>0 Then
			Sql = Sql & " Where ChannelID=" & ChannelID & ""
		End If
		Sql = Sql & " Order By OrderNum Asc,ID Desc"
		Call Exe_Conn(Rs,Sql,1)
		i = 0
		If Rs.BOF And Rs.EOF Then
			data = ""
		Else
			If Request("Page") <> "" Then
				CurrentPage = Code_CLng(Request("Page"))
			Else
				CurrentPage = 1
			End If
			MaxPerPage = Code_CLng(Trim(Request("limit")))
			If MaxPerPage <= 0 Then MaxPerPage = 10
			totalPut = Rs.RecordCount
			If CurrentPage < 1 Then
				CurrentPage = 1
			End If
			If (CurrentPage - 1) * MaxPerPage > totalPut Then
				If (totalPut Mod MaxPerPage) = 0 Then
					CurrentPage = totalPut \ MaxPerPage
				Else
					CurrentPage = totalPut \ MaxPerPage + 1
				End If
			End If
			If CurrentPage > 1 Then
				If (CurrentPage - 1) * MaxPerPage < totalPut Then
					Rs.Move (CurrentPage - 1) * MaxPerPage
				Else
					CurrentPage = 1
				End If
			End If
			Do While Not Rs.Eof
				If rs("ChannelID") > 0 Then
					sqlChannel = "select * from Channel where ChannelID=" & Code_CLng(rs("ChannelID"))
					Call Exec(rsChannel,sqlChannel,2)
					If rsChannel.BOF And rsChannel.EOF Then
						ChannelTit = ""
						rsChannel.Close
						Set rsChannel = Nothing
					Else
						ChannelTit = ToUnicode(Code_Html(rsChannel("ChannelTit"),1,0))
						rsChannel.Close
						Set rsChannel = Nothing
					End If
				End If
				If i=0 Then
					data = data & "{""id"":"&Rs("id")&",""field"":"""&Rs("field")&""",""FieldName"":"""&ToUnicode(Rs("FieldName"))&""",""ChannelName"":"""&ChannelTit&""",""mbbq"":""{$"&Rs("field")&"}"",""type"":"""&Rs("FieldType")&""",""required"":"""&Rs("NotNull")&""",""sort"":"""&Rs("OrderNum")&""",""disable"":"""&Rs("Recycle")&"""}"
				Else
					data = data & ",{""id"":"&Rs("id")&",""field"":"""&Rs("field")&""",""FieldName"":"""&ToUnicode(Rs("FieldName"))&""",""ChannelName"":"""&ChannelTit&""",""mbbq"":""{$"&Rs("field")&"}"",""type"":"""&Rs("FieldType")&""",""required"":"""&Rs("NotNull")&""",""sort"":"""&Rs("OrderNum")&""",""disable"":"""&Rs("Recycle")&"""}"
				End If
				iCount = iCount + 1
				If iCount >= MaxPerPage Then Exit Do
				Rs.MoveNext
				i=i+1
			Loop
			Rs.Close
		End If
		If totalPut = 0 Then
			Response.Write "{""code"":201,""msg"":""\u65e0\u6570\u636e""}" & vbCrLf
		Else
			Response.Write "{""code"":0,""msg"":""\u83b7\u53d6\u6210\u529f!"",""count"":"&totalPut&",""data"":["&data&"],""rel"":1}" & vbCrLf
		End If
		Response.End()
	Else
		Response.Write "<!DOCTYPE html>" & vbCrLf
		Response.Write "<head>" & vbCrLf
		Response.Write "<title>字段管理</title>" & vbCrlf
		Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
		Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
		Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
		Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
		Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/global.css"" media=""all"">" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/font.css"" media=""all"">" & vbCrLf
		Response.Write "<script type='text/javascript'>" & vbCrLf
		Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
		Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
		Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
		Response.Write "</head>" & vbCrlf
		Response.Write "<body>" & vbCrlf
		Response.Write "<div class=""admin-main layui-anim layui-anim-upbit"">" & vbCrLf
		Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrLf
		Response.Write "        <legend>字段列表</legend>" & vbCrLf
		Response.Write "    </fieldset>" & vbCrLf
		Response.Write "    <blockquote class=""layui-elem-quote"">" & vbCrLf
		Response.Write "        <a href=""?Action=Add&ChannelID=" & ChannelID & """ class=""layui-btn layui-btn-sm""><i class=""fa fa-plus""></i> 添加字段</a>" & vbCrLf
		Response.Write "        <a href=""javascript:void(0);"" onClick=""parent.tab.tabAdd({'id': 1,'href': 'Admin\/Admin_Channel.asp','title': '" & ToUnicode("模型列表") & "'});"" class=""layui-btn layui-btn-sm layui-btn-primary"">模型列表</a>" & vbCrLf
		Response.Write "    </blockquote>" & vbCrLf
		Response.Write "    <table class=""layui-table"" id=""list"" lay-filter=""list""></table>" & vbCrLf
		Response.Write "</div>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""required"">" & vbCrLf
		Response.Write "    {{# if(d.required==1){ }}" & vbCrLf
		Response.Write "    <i class=""icon icon-checkmark green""></i>" & vbCrLf
		Response.Write "    {{# }else{  }}" & vbCrLf
		Response.Write "    <i class=""icon icon-cross red""></i>" & vbCrLf
		Response.Write "    {{# } }}" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""action"">" & vbCrLf
		Response.Write "    {{# if(d.disable==1){ }}" & vbCrLf
		Response.Write "    <a href=""javascript:"" class=""layui-btn layui-btn-xs layui-btn-danger"" lay-event=""stateyes"">已禁用</a>" & vbCrLf
		Response.Write "    {{# }else{  }}" & vbCrLf
		Response.Write "    <a href=""javascript:"" class=""layui-btn layui-btn-xs layui-btn-warm"" lay-event=""stateyes"">已启用</a>" & vbCrLf
		Response.Write "    {{# } }}" & vbCrLf
		Response.Write "    <a href=""?Action=Modify&ID={{d.id}}"" class=""layui-btn layui-btn-xs""><i class=""fa fa-edit""></i> 编辑</a>" & vbCrLf
		Response.Write "    <a class=""layui-btn layui-btn-xs layui-btn-danger"" lay-event=""del""><i class=""fa fa-trash-o""></i> 删除</a>" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""order"">" & vbCrLf
		Response.Write "    <input name=""{{d.id}}"" data-id=""{{d.id}}"" class=""list_order layui-input"" value=""{{d.sort}}"" size=""10""/>" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script>" & vbCrLf
		Response.Write "    layui.use('table', function() {" & vbCrLf
		Response.Write "        var table = layui.table, $ = layui.jquery;" & vbCrLf
		Response.Write "        var tableIn=table.render({" & vbCrLf
		Response.Write "            elem: '#list'," & vbCrLf
		Response.Write "            url: '?Action=Main'," & vbCrLf
		Response.Write "            method: 'post'," & vbCrLf
		Response.Write "            where: {//设定异步数据接口的参数" & vbCrLf
		Response.Write "                ChannelID: '"&ChannelID&"'" & vbCrLf
		Response.Write "            }," & vbCrLf
		Response.Write "            cellMinWidth: 80," & vbCrLf
		Response.Write "            page:true," & vbCrLf
		Response.Write "            cols: [[" & vbCrLf
		'Response.Write "                {field: 'id', title: '编号', width:80, fixed: true}," & vbCrLf
		Response.Write "                {field: 'field', title: '字段名', width: 120, fixed: true}," & vbCrLf
		Response.Write "                {field: 'FieldName', title: '别名', width: 100, edit: 'text'}," & vbCrLf
		Response.Write "                {field: 'type', title: '字段类型', width: 100}," & vbCrLf
		Response.Write "                {field: 'ChannelName', title: '所属模型', width: 100}," & vbCrLf
		Response.Write "                {field: 'required', align: 'center', title: '必填', width: 80, toolbar: '#required'}," & vbCrLf
		Response.Write "                {field: 'mbbq', title: '模板标签', width: 200}," & vbCrLf
		Response.Write "                {field: 'sort', title: '排序', width: 100, sort: true,templet: '#order'}," & vbCrLf
		Response.Write "                {title: '操作', width: 220, align: 'center', toolbar: '#action'}" & vbCrLf
		Response.Write "            ]]" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "        //监听单元格编辑" & vbCrlf
		Response.Write "        table.on('edit(list)',function(obj) {" & vbCrlf
		Response.Write "            var value = obj.value, data = obj.data, field = obj.field;" & vbCrlf
		Response.Write "            $.ajax({" & vbCrLf
		Response.Write "                type: 'post'," & vbCrLf
		Response.Write "                url: '?Action=Update'," & vbCrLf
		Response.Write "                data: {ID:data.id,field:field,value:value}," & vbCrLf
		Response.Write "                dataType: 'json'," & vbCrLf
		Response.Write "                success: function(res) {" & vbCrLf
		Response.Write "                    if (res.code == 1) {" & vbCrlf
		Response.Write "                        layer.msg(res.msg, {time: 1000, icon: 1}, function () {" & vbCrlf
		Response.Write "                            tableIn.reload({ where: {ChannelID:'"&ChannelID&"'} });" & vbCrlf
		Response.Write "                        });" & vbCrlf
		Response.Write "                    }else{" & vbCrlf
		Response.Write "                        layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                    }" & vbCrlf
		Response.Write "                }" & vbCrLf
		Response.Write "            });" & vbCrLf
		Response.Write "        });" & vbCrlf
		Response.Write "        table.on('tool(list)', function(obj) {" & vbCrLf
		Response.Write "            var data = obj.data;" & vbCrLf
		Response.Write "            if (obj.event === 'stateyes') {" & vbCrLf
		Response.Write "                loading = layer.load(1, {shade: [0.1, '#fff']});" & vbCrLf
		Response.Write "                $.ajax({" & vbCrLf
		Response.Write "                    type: 'post'," & vbCrLf
		Response.Write "                    url: '?Action=FieldStatus'," & vbCrLf
		Response.Write "                    data: {id: data.id}," & vbCrLf
		Response.Write "                    dataType: 'json'," & vbCrLf
		Response.Write "                    success: function() {" & vbCrLf
		Response.Write "                        location.href = ""?ChannelID="&ChannelID&"""" & vbCrLf
		Response.Write "                    }" & vbCrLf
		Response.Write "                });" & vbCrLf
		Response.Write "            }else if(obj.event === 'del'){" & vbCrLf
		Response.Write "                    layer.confirm('你确定要删除该字段吗？', function(index){" & vbCrLf
		Response.Write "                    $.ajax({" & vbCrLf
		Response.Write "                        type: 'post'," & vbCrLf
		Response.Write "                        url: '?Action=Del'," & vbCrLf
		Response.Write "                        data: {id:data.id,ChannelID:'"&ChannelID&"'}," & vbCrLf
		Response.Write "                        dataType: 'json'," & vbCrLf
		Response.Write "                        success: function(res) {" & vbCrLf
		Response.Write "                            if (res.code == 1) {" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:1});" & vbCrLf
		Response.Write "                                obj.del();" & vbCrLf
		Response.Write "                            }else{" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                            }" & vbCrLf
		Response.Write "                        }" & vbCrLf
		Response.Write "                    });" & vbCrLf
		Response.Write "                    layer.close(index);" & vbCrLf
		Response.Write "                });" & vbCrLf
		Response.Write "            }" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "        $('body').on('blur','.list_order',function() {" & vbCrLf
		Response.Write "            var id = $(this).attr('data-id');" & vbCrLf
		Response.Write "            var sort = $(this).val();" & vbCrLf
		Response.Write "            var loading = layer.load(1, {shade: [0.1, '#fff']});" & vbCrLf
		Response.Write "            $.ajax({" & vbCrLf
		Response.Write "                type: 'post'," & vbCrLf
		Response.Write "                url: '?Action=ListOrder'," & vbCrLf
		Response.Write "                data: {id:id,sort:sort,ChannelID:"""&ChannelID&"""}," & vbCrLf
		Response.Write "                dataType: 'json'," & vbCrLf
		Response.Write "                success: function(res) {" & vbCrLf
		Response.Write "                    layer.close(loading);" & vbCrLf
		Response.Write "                    if (res.code == 1) {" & vbCrLf
		Response.Write "                        layer.msg(res.msg,{time:1000,icon:1});" & vbCrLf
		Response.Write "                        tableIn.reload();" & vbCrLf
		Response.Write "                    }else{" & vbCrLf
		Response.Write "                        layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                    }" & vbCrLf
		Response.Write "                }" & vbCrLf
		Response.Write "            });" & vbCrLf
		Response.Write "        })" & vbCrLf
		Response.Write "    });" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "</body>" & vbCrLf & "</html>"
	End If
End Sub

Sub Add()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>字段管理</title>" & vbCrlf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrlf
	Response.Write "<body>" & vbCrlf
	Response.Write "<script language=""JavaScript"">" & vbCrlf
	Response.Write "var Field_Setting = function(_this){" & vbCrlf
	Response.Write "	var fieldtpye=_this.options[_this.selectedIndex].value;" & vbCrlf
	Response.Write "	if(fieldtpye==""radio"" || fieldtpye==""checkbox"" || fieldtpye==""select""){" & vbCrlf
	Response.Write "		document.getElementById(""FieldOptions_Grid"").style.display="""";" & vbCrlf
	Response.Write "	}else{" & vbCrlf
	Response.Write "		document.getElementById(""FieldOptions_Grid"").style.display=""none"";" & vbCrlf
	Response.Write "	}" & vbCrlf
	Response.Write "	if(fieldtpye==""editor""){" & vbCrlf
	Response.Write "		document.getElementById(""SettingOptionMode"").style.display="""";" & vbCrlf
	Response.Write "	}else{" & vbCrlf
	Response.Write "		document.getElementById(""SettingOptionMode"").style.display=""none"";" & vbCrlf
	Response.Write "	}" & vbCrlf
	Response.Write "}" & vbCrlf
	Response.Write "</script>" & vbCrlf
	Response.Write "<form class='layui-form layui-form-pane' action=""" & strFileName & """ method=""post"" name=""myform"">" & vbCrlf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>添加字段</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">所属模型：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <div id=""ChannelID_outer"" ztype=""select"" class=""z-combox"" style=""display:inline-block; *zoom: 1;*display: inline;vertical-align:middle;height:auto;width:auto;position:relative;border:none 0;margin:0;padding:0;white-space: nowrap;"" _style=""width:100%;""><input type=""text"" ztype=""select"" id=""ChannelID"" name=""ChannelID"" tabindex=""-1"" autocomplete=""off"" class=""inputText"" style=""width:100%;position:absolute;z-index:-1;"" value=""" & ChannelID & """ startvalue=""" & ChannelID & """ lay-verify=""ChannelID""/><input type=""text"" id=""ChannelID_textField"" autocomplete=""off"" class=""inputText"" style=""vertical-align:middle; cursor:default;width:100%;"" /><a id=""ChannelID_spinner"" class=""z-combox-spinner"" style=""position:relative; left:-17px; margin-right:-15px; cursor:pointer; width:13px; height:15px;vertical-align:middle;""><b></b></a><div id=""ChannelID_list"" class=""optgroup"" style=""text-align:left;display:none;""><div id=""ChannelID_ul"" style=""left:-1px; width:-1px;""><script>Combox_ChannelID_Init=function(){var _el=Zving.getDom('ChannelID');if(_el._components){return true;}var  _data=[];var  _DataSource;_data.push(['','请选择...']);"
	Call Exec(RsChannel,"Select ChannelID,ChannelName from Channel where ChannelType<=1 And ChannelHidden=" & WK_False & " Order By ChannelOrder Asc,ChannelID Desc",2)
	Do While Not RsChannel.EOF
		Response.Write "_data.push(['" & RsChannel("ChannelID") & "','" & RsChannel("ChannelName") & "']);"
		RsChannel.movenext
	Loop
	Set RsChannel = Nothing
	Response.Write "var combox_ChannelID = new Zving.Selector({el:_el,data:_data,DataSource:_DataSource});};if(Zving.Page.isReady){Combox_ChannelID_Init();}else{Zving.Page.onReady(Combox_ChannelID_Init);}</script></div></div></div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字段名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""Field"" type=""text"" id=""Field"" size=""30"" MaxLength=""30"" value="""" lay-verify=""Field"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "        <div class=""layui-form-mid layui-word-aux"">只能由英文字母、数字和下划线组成，并且仅能字母开头，不以下划线结尾</div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">别名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""FieldName"" type=""text"" id=""FieldName"" size=""30"" MaxLength=""255"" value="""" lay-verify=""FieldName"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">默认值：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""FieldValue"" type=""text"" id=""FieldValue"" size=""30"" MaxLength=""255"" value="""" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">备注：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""FieldIntro"" type=""text"" id=""FieldIntro"" size=""30"" MaxLength=""255"" value="""" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字段类型：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <div id=""FieldType_outer"" ztype=""select"" class=""z-combox"" style=""display:inline-block; *zoom: 1;*display: inline;vertical-align:middle;height:auto;width:auto;position:relative;border:none 0;margin:0;padding:0;white-space: nowrap;"" _style=""width:100%;""><input type=""text"" ztype=""select"" id=""FieldType"" name=""FieldType"" tabindex=""-1"" autocomplete=""off"" class=""inputText"" style=""width:100%;position:absolute;z-index:-1;"" onchange=""Field_Setting(this);"" value="""" startvalue="""" lay-verify=""FieldType""/><input type=""text"" id=""FieldType_textField"" autocomplete=""off"" class=""inputText"" style=""vertical-align:middle; cursor:default;width:100%;"" /><a id=""FieldType_spinner"" class=""z-combox-spinner"" style=""position:relative; left:-17px; margin-right:-15px; cursor:pointer; width:13px; height:15px;vertical-align:middle;""><b></b></a><div id=""FieldType_list"" class=""optgroup"" style=""text-align:left;display:none;""><div id=""FieldType_ul"" style=""left:-1px; width:-1px;""><script>Combox_FieldType_Init=function(){var _el=Zving.getDom('FieldType');if(_el._components){return true;}var  _data=[];var  _DataSource;_data.push(['','请选择字段类型...']);_data.push(['text','单行文本']);_data.push(['textarea','多行文本']);_data.push(['editor','编辑器']);_data.push(['radio','单选按钮']);_data.push(['checkbox','复选框']);_data.push(['select','下拉选择']);_data.push(['number','数字']);_data.push(['datetime','日期时间']);_data.push(['image','图片']);_data.push(['zutu','组图']);_data.push(['file','附件']);var combox_FieldType = new Zving.Selector({el:_el,data:_data,DataSource:_DataSource});};if(Zving.Page.isReady){Combox_FieldType_Init();}else{Zving.Page.onReady(Combox_FieldType_Init);}</script></div></div></div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "<fieldset class=""layui-elem-field"" id=""SettingOptionMode"" style=""display:none;"">" & vbCrlf
	Response.Write "<div class=""layui-field-box"">" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">编辑器模式</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type=""radio"" value=""1"" name=""OptionMode"" title=""完整"" checked lay-filter='OptionMode'>" & vbCrlf
	Response.Write "            <input type=""radio"" value=""2"" name=""OptionMode"" title=""精简"" lay-filter='OptionMode'>" & vbCrlf
	Response.Write "            <input type=""radio"" value=""3"" name=""OptionMode"" title=""自定义"" lay-filter='OptionMode'>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item layui-form-text"" id=""SettingOptionTool"" style=""display:none;"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">工具栏：（必须严格按照Ueditor工具栏格式'fullscreen', 'source', '|', 'undo', 'redo'）</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <textarea name=""OptionTool"" id=""OptionTool"" cols=""60"" rows=""5"" class=""layui-textarea"">'bold', 'italic', 'underline'</textarea>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "</fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">必填：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type=""checkbox"" id=""NotNull"" name=""NotNull"" value=""1"" title=""必填"" lay-filter='NotNull'>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"" id=""Verification"" style=""display: none;"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">验证规则：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <div id=""Pattern_outer"" ztype=""select"" class=""z-combox"" style=""display:inline-block; *zoom: 1;*display: inline;vertical-align:middle;height:auto;width:auto;position:relative;border:none 0;margin:0;padding:0;white-space: nowrap;"" _style=""width:100%;""><input type=""text"" ztype=""select"" id=""Pattern"" name=""Pattern"" tabindex=""-1"" autocomplete=""off"" class=""inputText"" style=""width:100%;position:absolute;z-index:-1;"" value=""required"" startvalue=""required""/><input type=""text"" id=""Pattern_textField"" autocomplete=""off"" class=""inputText"" style=""vertical-align:middle; cursor:default;width:100%;"" /><a id=""Pattern_spinner"" class=""z-combox-spinner"" style=""position:relative; left:-17px; margin-right:-15px; cursor:pointer; width:13px; height:15px;vertical-align:middle;""><b></b></a><div id=""Pattern_list"" class=""optgroup"" style=""text-align:left;display:none;""><div id=""Pattern_ul"" style=""left:-1px; width:-1px;""><script>Combox_Pattern_Init=function(){var _el=Zving.getDom('Pattern');if(_el._components){return true;}var  _data=[];var  _DataSource;_data.push(['required','默认']);_data.push(['email','电子邮件']);_data.push(['url','网址']);_data.push(['date','日期']);_data.push(['number','数字']);_data.push(['phone','手机号码']);_data.push(['identity','身份证号']);var combox_Pattern = new Zving.Selector({el:_el,data:_data,DataSource:_DataSource});};if(Zving.Page.isReady){Combox_Pattern_Init();}else{Zving.Page.onReady(Combox_Pattern_Init);}</script></div></div></div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"" id=""Verification2"" style=""display: none;"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字符长度：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-inline"" style=""width: 100px;"">" & vbCrlf
	Response.Write "            <input type=""text"" name=""MinLength"" value="""" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "        <div class=""layui-form-mid"">-</div>" & vbCrlf
	Response.Write "        <div class=""layui-input-inline"" style=""width: 100px;"">" & vbCrlf
	Response.Write "            <input type=""text"" name=""MaxLength"" value="""" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"" id=""Verification3"" style=""display: none;"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">错误信息：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type=""text"" name=""ErrorMsg"" value="""" placeholder=""验证失败错误信息"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item layui-form-text"" id=""FieldOptions_Grid"" style=""display:none;"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">备选内容：（一行代表一个选项，实例：值|名称）</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <textarea name=""FieldOptions"" id=""FieldOptions"" cols=""60"" rows=""5"" class=""layui-textarea"" lay-verify=""FieldOptions""></textarea>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item layui-form-text"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字段提示：（填写该字段表单信息时的提示文字）</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <textarea name=""FieldTips"" id=""FieldTips"" cols=""60"" rows=""5"" MaxLength=""255"" class=""layui-textarea""></textarea>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <div class=""layui-inline"">" & vbCrlf
	Response.Write "            <label class=""layui-form-label"">排序：</label>" & vbCrlf
	Response.Write "            <div class=""layui-input-inline"">" & vbCrlf
	Response.Write "                <input name=""OrderNum"" type=""number"" min=""0"" id=""OrderNum"" MaxLength=""10"" value=""0"" class=""layui-input"">" & vbCrlf
	Response.Write "            </div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<input type=""hidden"" name=""Action"" value=""SaveAdd"">" & Submit_Layui("提交添加","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrlf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //自定义表单验证" & vbCrlf
	Response.Write "    form.verify({" & vbCrlf
	Response.Write "        ChannelID: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""所属模型不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        Field: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""字段名不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        FieldName: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""别名不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        FieldType: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""字段类型不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        FieldOptions: function (value, item) {" & vbCrlf
 	Response.Write "            if ($('#FieldType').value==""radio""||$('#FieldType').value==""checkbox""||$('#FieldType').value==""select"") {" & vbCrlf
	Response.Write "                if (!value){" & vbCrlf
	Response.Write "                    item.focus();" & vbCrlf
	Response.Write "                    return ""备选内容不能为空！请填写！"";" & vbCrlf
 	Response.Write "                }" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //监听编辑器模式" & vbCrlf
	Response.Write "    form.on('radio(OptionMode)', function(data){" & vbCrlf
	Response.Write "        if(data.value==3){" & vbCrlf
	Response.Write "            SettingOptionTool.style.display='';" & vbCrlf
	Response.Write "        }else{" & vbCrlf
	Response.Write "            SettingOptionTool.style.display='none';" & vbCrlf
	Response.Write "        }" & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //监听NotNull" & vbCrlf
	Response.Write "    form.on('checkbox(NotNull)', function(data){" & vbCrlf
	Response.Write "        rNotNull();" & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveAdd'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub Modify()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>字段管理</title>" & vbCrlf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrlf
	Response.Write "<body>" & vbCrlf
	ID=request("ID")
	Call Exe_Conn(rs,"select * from "&Data_Name&" where ID="&ID,1)
	if rs.eof Then
		rs.close
		Response.Write IsSuccess("字段ID（"&id&"）不存在！",AdminFolder & "/Admin/"&strFileName)
		exit sub
	End If
	If rs("FieldType")="radio" Or rs("FieldType")="checkbox" Or rs("FieldType")="select" Then
		IsShowOptions=True
	End If
	Response.Write "<script language=""JavaScript"">" & vbCrlf
	Response.Write "var Field_Setting = function(_this){" & vbCrlf
	Response.Write "	var fieldtpye=_this.options[_this.selectedIndex].value;" & vbCrlf
	Response.Write "	if(fieldtpye==""radio"" || fieldtpye==""checkbox"" || fieldtpye==""select""){" & vbCrlf
	Response.Write "		document.getElementById(""FieldOptions_Grid"").style.display="""";" & vbCrlf
	Response.Write "	}else{" & vbCrlf
	Response.Write "		document.getElementById(""FieldOptions_Grid"").style.display=""none"";" & vbCrlf
	Response.Write "	}" & vbCrlf
	Response.Write "	if(fieldtpye==""editor""){" & vbCrlf
	Response.Write "		document.getElementById(""SettingOptionMode"").style.display="""";" & vbCrlf
	Response.Write "	}else{" & vbCrlf
	Response.Write "		document.getElementById(""SettingOptionMode"").style.display=""none"";" & vbCrlf
	Response.Write "	}" & vbCrlf
	Response.Write "}" & vbCrlf
	Response.Write "</script>" & vbCrlf
	Response.Write "<form class='layui-form layui-form-pane' action=""" & strFileName & "?ChannelID=" & rs("ChannelID") & "&FieldType=" & rs("FieldType") & """ method=""post"" name=""myform"">" & vbCrlf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>编辑字段</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">所属模型：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <div id=""ChannelID_outer"" ztype=""select"" class=""z-combox"" style=""display:inline-block; *zoom: 1;*display: inline;vertical-align:middle;height:auto;width:auto;position:relative;border:none 0;margin:0;padding:0;white-space: nowrap;"" _style=""width:100%;""><input type=""text"" ztype=""select"" id=""ChannelID"" name=""ChannelID"" tabindex=""-1"" autocomplete=""off"" class=""inputText"" style=""width:100%;position:absolute;z-index:-1;"" value=""" & rs("ChannelID") & """ startvalue=""" & rs("ChannelID") & """ lay-verify=""ChannelID"" disabled/><input type=""text"" id=""ChannelID_textField"" autocomplete=""off"" class=""inputText"" style=""vertical-align:middle; cursor:default;width:100%;"" /><a id=""ChannelID_spinner"" class=""z-combox-spinner"" style=""position:relative; left:-17px; margin-right:-15px; cursor:pointer; width:13px; height:15px;vertical-align:middle;""><b></b></a><div id=""ChannelID_list"" class=""optgroup"" style=""text-align:left;display:none;""><div id=""ChannelID_ul"" style=""left:-1px; width:-1px;""><script>Combox_ChannelID_Init=function(){var _el=Zving.getDom('ChannelID');if(_el._components){return true;}var  _data=[];var  _DataSource;_data.push(['','请选择...']);"
	Call Exec(RsChannel,"Select ChannelID,ChannelName from Channel where ChannelType<=1 And ChannelHidden=" & WK_False & " Order By ChannelOrder Asc,ChannelID Desc",2)
	Do While Not RsChannel.EOF
		Response.Write "_data.push(['" & RsChannel("ChannelID") & "','" & RsChannel("ChannelName") & "']);"
		RsChannel.movenext
	Loop
	Set RsChannel = Nothing
	Response.Write "var combox_ChannelID = new Zving.Selector({el:_el,data:_data,DataSource:_DataSource});};if(Zving.Page.isReady){Combox_ChannelID_Init();}else{Zving.Page.onReady(Combox_ChannelID_Init);}</script></div></div></div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字段名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""Field"" type=""text"" id=""Field"" size=""30"" MaxLength=""30"" value=""" & rs("Field") & """ lay-verify=""Field"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "        <div class=""layui-form-mid layui-word-aux"">只能由英文字母、数字和下划线组成，并且仅能字母开头，不以下划线结尾</div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">别名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""FieldName"" type=""text"" id=""FieldName"" size=""30"" MaxLength=""255"" value=""" & rs("FieldName") & """ lay-verify=""FieldName"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">默认值：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""FieldValue"" type=""text"" id=""FieldValue"" size=""30"" MaxLength=""255"" value=""" & rs("FieldValue") & """ class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">备注：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""FieldIntro"" type=""text"" id=""FieldIntro"" size=""30"" MaxLength=""255"" value=""" & rs("FieldIntro") & """ class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字段类型：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <div id=""FieldType_outer"" ztype=""select"" class=""z-combox"" style=""display:inline-block; *zoom: 1;*display: inline;vertical-align:middle;height:auto;width:auto;position:relative;border:none 0;margin:0;padding:0;white-space: nowrap;"" _style=""width:100%;""><input type=""text"" ztype=""select"" id=""FieldType"" name=""FieldType"" tabindex=""-1"" autocomplete=""off"" class=""inputText"" style=""width:100%;position:absolute;z-index:-1;"" onchange=""Field_Setting(this);"" value=""" & rs("FieldType") & """ startvalue=""" & rs("FieldType") & """ lay-verify=""FieldType"" disabled/><input type=""text"" id=""FieldType_textField"" autocomplete=""off"" class=""inputText"" style=""vertical-align:middle; cursor:default;width:100%;"" /><a id=""FieldType_spinner"" class=""z-combox-spinner"" style=""position:relative; left:-17px; margin-right:-15px; cursor:pointer; width:13px; height:15px;vertical-align:middle;""><b></b></a><div id=""FieldType_list"" class=""optgroup"" style=""text-align:left;display:none;""><div id=""FieldType_ul"" style=""left:-1px; width:-1px;""><script>Combox_FieldType_Init=function(){var _el=Zving.getDom('FieldType');if(_el._components){return true;}var  _data=[];var  _DataSource;_data.push(['','请选择字段类型...']);_data.push(['text','单行文本']);_data.push(['textarea','多行文本']);_data.push(['editor','编辑器']);_data.push(['radio','单选按钮']);_data.push(['checkbox','复选框']);_data.push(['select','下拉选择']);_data.push(['number','数字']);_data.push(['datetime','日期时间']);_data.push(['image','图片']);_data.push(['zutu','组图']);_data.push(['file','附件']);var combox_FieldType = new Zving.Selector({el:_el,data:_data,DataSource:_DataSource});};if(Zving.Page.isReady){Combox_FieldType_Init();}else{Zving.Page.onReady(Combox_FieldType_Init);}</script></div></div></div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "<fieldset class=""layui-elem-field"" id=""SettingOptionMode"""
	If rs("FieldType")<>"editor" Then
		Response.Write " style=""display:none;"""
	End If
	Response.Write ">" & vbCrlf
	Response.Write "<div class=""layui-field-box"">" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">编辑器模式</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type=""radio"" value=""1"" name=""OptionMode"" title=""完整"" lay-filter='OptionMode'"
	If rs("OptionMode")=1 Then
		Response.Write " checked"
	End If
	Response.Write ">" & vbCrlf
	Response.Write "            <input type=""radio"" value=""2"" name=""OptionMode"" title=""精简"" lay-filter='OptionMode'"
	If rs("OptionMode")=2 Then
		Response.Write " checked"
	End If
	Response.Write ">" & vbCrlf
	Response.Write "            <input type=""radio"" value=""3"" name=""OptionMode"" title=""自定义"" lay-filter='OptionMode'"
	If rs("OptionMode")=3 Then
		Response.Write " checked"
	End If
	Response.Write ">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item layui-form-text"" id=""SettingOptionTool"""
	If rs("OptionMode")<>3 Then
		Response.Write " style=""display:none;"""
	End If
	Response.Write ">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">工具栏：（必须严格按照Ueditor工具栏格式'fullscreen', 'source', '|', 'undo', 'redo'）</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <textarea name=""OptionTool"" id=""OptionTool"" cols=""60"" rows=""5"" class=""layui-textarea"">" & rs("OptionTool") & "</textarea>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "</fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">必填：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type=""checkbox"" id=""NotNull"" name=""NotNull"" value=""1"" title=""必填"" lay-filter='NotNull'"
	If rs("NotNull")=1 Then
		Response.Write " checked"
	End If
	Response.Write ">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"" id=""Verification"""
	If rs("NotNull")=0 Then
		Response.Write " style=""display: none;"""
	End If
	Response.Write ">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">验证规则：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <div id=""Pattern_outer"" ztype=""select"" class=""z-combox"" style=""display:inline-block; *zoom: 1;*display: inline;vertical-align:middle;height:auto;width:auto;position:relative;border:none 0;margin:0;padding:0;white-space: nowrap;"" _style=""width:100%;""><input type=""text"" ztype=""select"" id=""Pattern"" name=""Pattern"" tabindex=""-1"" autocomplete=""off"" class=""inputText"" style=""width:100%;position:absolute;z-index:-1;"" value=""" & rs("Pattern") & """ startvalue=""" & rs("Pattern") & """/><input type=""text"" id=""Pattern_textField"" autocomplete=""off"" class=""inputText"" style=""vertical-align:middle; cursor:default;width:100%;"" /><a id=""Pattern_spinner"" class=""z-combox-spinner"" style=""position:relative; left:-17px; margin-right:-15px; cursor:pointer; width:13px; height:15px;vertical-align:middle;""><b></b></a><div id=""Pattern_list"" class=""optgroup"" style=""text-align:left;display:none;""><div id=""Pattern_ul"" style=""left:-1px; width:-1px;""><script>Combox_Pattern_Init=function(){var _el=Zving.getDom('Pattern');if(_el._components){return true;}var  _data=[];var  _DataSource;_data.push(['required','默认']);_data.push(['email','电子邮件']);_data.push(['url','网址']);_data.push(['date','日期']);_data.push(['number','数字']);_data.push(['phone','手机号码']);_data.push(['identity','身份证号']);var combox_Pattern = new Zving.Selector({el:_el,data:_data,DataSource:_DataSource});};if(Zving.Page.isReady){Combox_Pattern_Init();}else{Zving.Page.onReady(Combox_Pattern_Init);}</script></div></div></div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"" id=""Verification2"""
	If rs("NotNull")=0 Then
		Response.Write " style=""display: none;"""
	End If
	Response.Write ">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字符长度：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-inline"" style=""width: 100px;"">" & vbCrlf
	Response.Write "            <input type=""text"" name=""MinLength"" value=""" & rs("MinLength") & """ class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "        <div class=""layui-form-mid"">-</div>" & vbCrlf
	Response.Write "        <div class=""layui-input-inline"" style=""width: 100px;"">" & vbCrlf
	Response.Write "            <input type=""text"" name=""MaxLength"" value=""" & rs("MaxLength") & """ class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"" id=""Verification3"""
	If rs("NotNull")=0 Then
		Response.Write " style=""display: none;"""
	End If
	Response.Write ">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">错误信息：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type=""text"" name=""ErrorMsg"" value=""" & rs("ErrorMsg") & """ placeholder=""验证失败错误信息"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item layui-form-text"" id=""FieldOptions_Grid"""
	If IsShowOptions=False Then Response.Write " style=""display:none;"""
	Response.Write ">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">备选内容：（一行代表一个选项，实例：值|名称）</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <textarea name=""FieldOptions"" id=""FieldOptions"" cols=""60"" rows=""5"" lay-verify=""FieldOptions"" class=""layui-textarea"">" & Replace(rs("FieldOptions"),",",Chr(10)) & "</textarea>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item layui-form-text"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">字段提示：（填写该字段表单信息时的提示文字）</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <textarea name=""FieldTips"" id=""FieldTips"" cols=""60"" rows=""5"" MaxLength=""255"" class=""layui-textarea"">" & rs("FieldTips") & "</textarea>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <div class=""layui-inline"">" & vbCrlf
	Response.Write "            <label class=""layui-form-label"">排序：</label>" & vbCrlf
	Response.Write "            <div class=""layui-input-inline"">" & vbCrlf
	Response.Write "                <input name=""OrderNum"" type=""number"" min=""0"" id=""OrderNum"" MaxLength=""10"" value=""" & rs("OrderNum") & """ class=""layui-input"">" & vbCrlf
	Response.Write "            </div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<input name=""OldField"" type=""hidden"" id=""OldField"" value=""" & rs("Field") & """><input name=""ID"" type=""hidden"" id=""ID"" value=""" & ID & """><input type=""hidden"" name=""Action"" value=""SaveModify"">" & Submit_Layui("提交修改","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrlf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //自定义表单验证" & vbCrlf
	Response.Write "    form.verify({" & vbCrlf
	Response.Write "        ChannelID: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""所属模型不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        Field: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""字段名不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        FieldName: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""别名不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        FieldType: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""字段类型不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        FieldOptions: function (value, item) {" & vbCrlf
 	Response.Write "            if ($('#FieldType').value==""radio""||$('#FieldType').value==""checkbox""||$('#FieldType').value==""select"") {" & vbCrlf
	Response.Write "                if (!value){" & vbCrlf
	Response.Write "                    item.focus();" & vbCrlf
	Response.Write "                    return ""备选内容不能为空！请填写！"";" & vbCrlf
 	Response.Write "                }" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //监听编辑器模式" & vbCrlf
	Response.Write "    form.on('radio(OptionMode)', function(data){" & vbCrlf
	Response.Write "        if(data.value==3){" & vbCrlf
	Response.Write "            SettingOptionTool.style.display='';" & vbCrlf
	Response.Write "        }else{" & vbCrlf
	Response.Write "            SettingOptionTool.style.display='none';" & vbCrlf
	Response.Write "        }" & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //监听NotNull" & vbCrlf
	Response.Write "    form.on('checkbox(NotNull)', function(data){" & vbCrlf
	Response.Write "        rNotNull();" & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveModify'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub SaveAdd()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		dim ChannelID,Field,FieldName,FieldValue,FieldIntro,FieldType,OptionMode,OptionTool,NotNull,FieldOptions,FieldTips,Pattern,MinLength,MaxLength,ErrorMsg,OrderNum,ID
		ChannelID=Trim(Request.Form("ChannelID"))
		Field=Trim(Request.Form("Field"))
		FieldName=Trim(Request.Form("FieldName"))
		FieldValue=Trim(Request.Form("FieldValue"))
		FieldIntro=Trim(Request.Form("FieldIntro"))
		FieldType=Trim(Request.Form("FieldType"))
		OptionMode=Trim(Request.Form("OptionMode"))
		OptionTool=Trim(Request.Form("OptionTool"))
		NotNull=Code_CLng(Request.Form("NotNull"))
		FieldOptions=Trim(Request.Form("FieldOptions"))
		FieldTips=Trim(Request.Form("FieldTips"))
		Pattern=Trim(Request.Form("Pattern"))
		MinLength=Trim(Request.Form("MinLength"))
		MaxLength=Trim(Request.Form("MaxLength"))
		ErrorMsg=Trim(Request.Form("ErrorMsg"))
		OrderNum=Code_CLng(Request.Form("OrderNum"))
		If OrderNum<0 Then OrderNum = 0
		
		FieldOptions = Replace(FieldOptions,Chr(10),",")
		FieldOptions = Replace(FieldOptions,Chr(13),"")
		FieldOptions = Replace(FieldOptions,"<br>","")
		FieldOptions = Replace(FieldOptions,"<br/>","")
		
		If ChannelID="" Then
			Response.Write "{""code"":0,""msg"":""\u6240\u5c5e\u9891\u9053\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If Field="" Then
			Response.Write "{""code"":0,""msg"":""\u5b57\u6bb5\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FieldName="" Then
			Response.Write "{""code"":0,""msg"":""\u522b\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FieldType="" Then
			Response.Write "{""code"":0,""msg"":""\u5b57\u6bb5\u7c7b\u578b\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FieldType="radio" Or FieldType="checkbox" Or FieldType="select" Then
			If FieldOptions="" Then
				Response.Write "{""code"":0,""msg"":""\u5907\u9009\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
				Response.End()
			End If
		End If
		
		If FoundErr = True Then Exit Sub
		
		ID = GetNewID(Data_Name, "ID")
		sql="select * from "&Data_Name&" where ChannelID=" & ChannelID & " and Field='" & Field & "'"
		Call Exe_Conn(rs,sql,3)
		If Not (rs.BOF And rs.EOF) Then
			Response.Write "{""code"":0,""msg"":""\u6570\u636e\u5e93\u4e2d\u5df2\u7ecf\u5b58\u5728\u6b64\u5b57\u6bb5\uff01""}" & vbCrLf
			Response.End()
			rs.Close
			Set rs = Nothing
			Exit Sub
		End If
		rs.addnew
		rs("ID")=ID
		rs("ChannelID")=ChannelID
		rs("Field")=Field
		rs("FieldName")=FieldName
		rs("FieldValue")=FieldValue
		rs("FieldIntro")=FieldIntro
		rs("FieldType")=FieldType
		rs("OptionMode")=OptionMode
		rs("OptionTool")=OptionTool
		rs("NotNull")=NotNull
		rs("FieldOptions")=FieldOptions
		rs("FieldTips")=FieldTips
		rs("Pattern")=Pattern
		rs("MinLength")=MinLength
		rs("MaxLength")=MaxLength
		rs("ErrorMsg")=ErrorMsg
		rs("OrderNum")=OrderNum
		rs("Recycle")=0
		rs.Update
		rs.Close
		Set rs = Nothing
		If ChannelID > 0 Then
			Call GetChannel(ChannelID)
		End If
		If(len(ChannelDataName)<1) Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u8868\u540d\uff01""}" & vbCrLf
			Response.End()
		End If
		If(len(Field)<1) Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u5b57\u6bb5\u540d\uff01""}" & vbCrLf
			Response.End()
		End If
		If(len(FieldType)<1) Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u5b57\u6bb5\u7c7b\u578b\uff01""}" & vbCrLf
			Response.End()
		End If
		sql = "Alter Table "&ChannelDataName&" Add "&Field&" "&CreateFieldDataType(FieldType,ChannelIDDatabaseType)&" NULL"
		Call Exec("",sql,0)
		On Error Resume Next
		Set Cat = Server.CreateObject("ADOX.Catalog")
		Set Fld = Server.CreateObject("ADOX.Column")
		Cat.ActiveConnection=Conn
		Cat.Tables(ChannelDataName).Columns(Field).Type = FieldType
		Cat.Tables(ChannelDataName).Columns(Field).DefinedSize = 255
		Cat.Tables(ChannelDataName).Columns(Field).Properties("Default").Value = FieldValue
		Cat.Tables(ChannelDataName).Columns(Field).Properties("Description").Value = FieldIntro
		Response.Write "{""code"":1,""msg"":""\u5b57\u6bb5\u6dfb\u52a0\u6210\u529f\uff01"",""url"":""?ChannelID="&ChannelID&"""}" & vbCrLf
		Response.End()
		Exit Sub
	End If
End Sub

Sub SaveModify()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		dim ChannelID,Field,OldField,FieldName,FieldValue,FieldIntro,FieldType,OptionMode,OptionTool,NotNull,FieldOptions,FieldTips,Pattern,MinLength,MaxLength,ErrorMsg,OrderNum,ID
		ID=Trim(Request.Form("ID"))
		ChannelID=Request("ChannelID")
		Field=Trim(Request.Form("Field"))
		OldField=Trim(Request.Form("OldField"))
		FieldName=Trim(Request.Form("FieldName"))
		FieldValue=Trim(Request.Form("FieldValue"))
		FieldIntro=Trim(Request.Form("FieldIntro"))
		FieldType=Trim(Request.Form("FieldType"))
		OptionMode=Trim(Request.Form("OptionMode"))
		OptionTool=Trim(Request.Form("OptionTool"))
		NotNull=Code_CLng(Request.Form("NotNull"))
		FieldOptions=Trim(Request.Form("FieldOptions"))
		FieldTips=Trim(Request.Form("FieldTips"))
		Pattern=Trim(Request.Form("Pattern"))
		MinLength=Trim(Request.Form("MinLength"))
		MaxLength=Trim(Request.Form("MaxLength"))
		ErrorMsg=Trim(Request.Form("ErrorMsg"))
		OrderNum=Code_CLng(Request.Form("OrderNum"))
		If OrderNum<0 Then OrderNum = 0
		
		FieldOptions = Replace(FieldOptions,Chr(10),",")
		FieldOptions = Replace(FieldOptions,Chr(13),"")
		FieldOptions = Replace(FieldOptions,"<br>","")
		FieldOptions = Replace(FieldOptions,"<br/>","")
		
		If ChannelID="" Then
			Response.Write "{""code"":0,""msg"":""\u6240\u5c5e\u9891\u9053\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If Field="" Then
			Response.Write "{""code"":0,""msg"":""\u5b57\u6bb5\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FieldName="" Then
			Response.Write "{""code"":0,""msg"":""\u522b\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FieldType="" Then
			Response.Write "{""code"":0,""msg"":""\u5b57\u6bb5\u7c7b\u578b\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FieldType="radio" Or FieldType="checkbox" Or FieldType="select" Then
			If FieldOptions="" Then
				Response.Write "{""code"":0,""msg"":""\u5907\u9009\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
				Response.End()
			End If
		End If
		
		If FoundErr = True Then Exit Sub
		
		sql="select * from "&Data_Name&" where ID=" & ID
		Call Exe_Conn(Rs,Sql,3)
		rs("ChannelID")=ChannelID
		rs("Field")=Field
		rs("FieldName")=FieldName
		rs("FieldValue")=FieldValue
		rs("FieldIntro")=FieldIntro
		rs("FieldType")=FieldType
		rs("OptionMode")=OptionMode
		rs("OptionTool")=OptionTool
		rs("NotNull")=NotNull
		rs("FieldOptions")=FieldOptions
		rs("FieldTips")=FieldTips
		rs("Pattern")=Pattern
		rs("MinLength")=MinLength
		rs("MaxLength")=MaxLength
		rs("ErrorMsg")=ErrorMsg
		rs("OrderNum")=OrderNum
		'rs("Recycle")=0
		rs.Update
		rs.Close
		Set rs = Nothing
		If ChannelID > 0 Then
			Call GetChannel(ChannelID)
		End If
		If(len(ChannelDataName)<1) Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u8868\u540d\uff01""}" & vbCrLf
			Response.End()
		End If
		If(len(Field)<1) Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u5b57\u6bb5\u540d\uff01""}" & vbCrLf
			Response.End()
		End If
		If(len(FieldType)<1) Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u5b57\u6bb5\u7c7b\u578b\uff01""}" & vbCrLf
			Response.End()
		End If
		On Error Resume Next
		Set Cat = Server.CreateObject("ADOX.Catalog")
		Set Fld = Server.CreateObject("ADOX.Column")
		Cat.ActiveConnection=Conn
		Set mytable = Server.CreateObject("ADOX.Table")
		Set mytable = Cat.Tables(ChannelDataName)
		mytable.Columns(OldField).Name = Field
		sql = "Alter Table [" & ChannelDataName & "] ALTER COLUMN [" & Field & "] "&CreateFieldDataType(FieldType,ChannelIDDatabaseType)&" NULL"
		Call Exec("",sql,0)
		Cat.Tables(ChannelDataName).Columns(Field).Type = FieldType
		Cat.Tables(ChannelDataName).Columns(Field).DefinedSize = 255
		Cat.Tables(ChannelDataName).Columns(Field).Properties("Default").Value = FieldValue
		Cat.Tables(ChannelDataName).Columns(Field).Properties("Description").Value = FieldIntro
		Response.Write "{""code"":1,""msg"":""\u5b57\u6bb5\u4fee\u6539\u6210\u529f\uff01"",""url"":""?ChannelID="&ChannelID&"""}" & vbCrLf
		Response.End()
		Exit Sub
	End If
End Sub

Sub FieldStatus()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		ID = Code_CLng(Trim(Code_Form("ID")))
		Sql = "Select * From "&Data_Name&" Where ID="&ID
		Call Exec(Rs,Sql,2)
		If Rs("Recycle") = 0 Then
			Recycle = 1
		Else
			Recycle = 0
		End If
		Call Exec("","Update ["&Data_Name&"] Set Recycle="&Recycle&" Where ID="&ID,0)
		Response.Write "{""msg"":""\u4fee\u6539\u6210\u529f"",""code"":1}"
		Response.End()
	End If
End Sub

Sub ListOrder()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		ID = Code_CLng(Trim(Code_Form("ID")))
		ChannelID = Code_CLng(Trim(Code_Form("ChannelID")))
		OrderNum = Code_CLng(Trim(Code_Form("sort")))
		Call Exec("","Update ["&Data_Name&"] Set OrderNum="&OrderNum&" Where ID="&ID,0)
		Response.Write "{""msg"":""\u6392\u5e8f\u6210\u529f\uff01"",""url"":""?ChannelID="&ChannelID&""",""code"":1}"
		Response.End()
	End If
End Sub

Sub Update()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim ID
		ID = Trim(Code_Form("ID"))
		field = Trim(Code_Form("field"))
		value = Trim(Code_Form("value"))
		If ID = "" Then
			Response.Write "{""msg"":""\u8bf7\u6307\u5b9a\u8981\u5220\u9664\u7684\u6765\u6e90ID\uff01"",""code"":0}"
			Response.End()
		End If
		Call Exec("","Update ["&Data_Name&"] Set "&field&"='"&value&"' where ID=" & ID,0)
		Response.Write "{""msg"":""\u7f16\u8f91\u6210\u529f\uff01"",""code"":1}"
		Response.End()
	End If
End Sub

Sub Del()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		ID = Code_CLng(Trim(Code_Form("ID")))
		Fn_Sql = "SELECT * FROM ["&Data_Name&"] WHERE ID="& ID &""
		Call Exec(Fn_Rs,Fn_Sql,2)
		If Not(Fn_Rs.Eof) Then
			IsContentExist = True
			Field = Fn_Rs("Field")
			FieldName = Fn_Rs("FieldName")
			ChannelID = Fn_Rs("ChannelID")
		Else
			IsContentExist = False
		End If
		'开始执行操作
		If ChannelID > 0 Then
			Call GetChannel(ChannelID)
		End If
		If Action = "Del" And IsContentExist Then
			If(len(ChannelDataName)<1) Then
				Response.Write "{""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u8868\u540d\uff01"",""code"":0}"
				Response.End()
			End If
			If(len(Field)<1) Then
				Response.Write "{""msg"":""\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u5b57\u6bb5\u540d\uff01"",""code"":0}"
				Response.End()
			End If
			Call Exec("","ALTER TABLE "&ChannelDataName&" DROP COLUMN "&Field,0)
			Call Exec("","Delete From "&Data_Name&" Where ID=" & ID,0)
		End If
		Response.Write "{""msg"":""\u5220\u9664\u6210\u529f\uff01"",""code"":1}"
		Response.End()
	End If
End Sub

Function CreateFieldDataType(ByVal BV_FieldType,ByVal DB_Type)
	Dim Fn_Return
	Select Case DB_Type
	Case 0
		If BV_FieldType="editor" Then
			Fn_Return = "memo"
		ElseIf BV_FieldType="number" Then
			Fn_Return = "number"
		ElseIf BV_FieldType="datetime" Then
			Fn_Return = "date"
		ElseIf BV_FieldType="checkbox" Then
			Fn_Return = "memo"
		Else
			Fn_Return = "text (250)"
		End If
	Case 1
		If BV_FieldType="editor" Then
			Fn_Return = "[ntext]"
		ElseIf BV_FieldType="number" Then
			Fn_Return = "[int]"
		ElseIf BV_FieldType="datetime" Then
			Fn_Return = "[datetime]"
		ElseIf BV_FieldType="checkbox" Then
			Fn_Return = "[ntext]"
		Else
			Fn_Return = "[nvarchar] (250)"
		End If
	End Select
	CreateFieldDataType = Fn_Return
End Function
%>